class Solution {
    unordered_map<int,int> map;
    int max_value=0;
public:
    void Visit(TreeNode* root)
    {
        if(root==nullptr)  return;
        map[root->val]++;
        if(map[root->val]>max_value)  max_value=map[root->val];
        if(root->left!=nullptr)  Visit(root->left);
        if(root->right!=nullptr)  Visit(root->right);
    }
    vector<int> findMode(TreeNode* root) {
        Visit(root);
        vector<int> res;
        for(const auto& [key, value]:map){
            if(value==max_value){
                res.emplace_back(key);
            }
        }
        return res;
    }
};